home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / S / Smaller Installer 1.0.2 / Hook Proc Examples / QD32Hook / QD32Hook.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-17  |  5.0 KB  |  141 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2. *                                                                                                        *
  3. *                                         Smaller Installerâ„¢                                        *
  4. *                                                                                                        *
  5. *                                        Â© 1992 Bill Goodman                                        *
  6. *                                        All Rights Reserved                                        *
  7. *                                                                                                        *
  8. *******************************************************************************
  9.  
  10. Quickdraw Hook Example
  11.  
  12. This installer hook procedure checks that the target machine is running System
  13. 6.0.5 or higher. It also installs the 32-bit Quickdraw file if the target
  14. machine is not running version 1.2 or higher. The hook procedure installs the
  15. Quickdraw file by enabling installation group "P" so the installer will install
  16. the 32-bit Quickdraw file in the system folder.
  17.  
  18. To use this hook procedure, you must compile this code and create a code
  19. resource with type 'SICR' and an ID of 500.  This resource should be
  20. non-preloaded, nonpurgeable, unlocked, unprotected and non-sysheap.  Copy this
  21. resource and the ALRT/DITL resources from the "QD32Hook.ALRT.rsrc" file to your
  22. installer's resource file. Add the 32-bit Quickdraw file to your source archive
  23. using the following path: "{P}:$SYSTEM:32-Bit QuickDraw"
  24.  
  25. ******************************************************************************/
  26.  
  27. #include <SetUpA4.h>
  28. #include <GestaltEqu.h>
  29. #include "SIHookProc.h"
  30.  
  31.  
  32. /******************************************************************************
  33.     Module Internal Function Prototypes
  34. ******************************************************************************/
  35. void SetTargetVolFunction(void);
  36. void BeginInstallFunction(void);
  37.  
  38.  
  39. /******************************************************************************
  40.     Constant Declarations
  41. ******************************************************************************/
  42. #define groupPMask        0x8000    /* Group "P" selection mask */
  43.  
  44. /* Alert Definitions */
  45. #define sysRequiredAlrt        500    /* "Meteor requires version 6.0.5 or newer of the system software." */
  46.  
  47.  
  48. /******************************************************************************
  49.     Module Variables Declarations
  50. ******************************************************************************/
  51. SIHookParmBlk *parms;                    /* Global pointer to parameter block */
  52. Boolean gestaltFailed = false;        /* Set if Gestalt could not return result */
  53. unsigned char emptyPStr[] = "\p";    /* Empty Pascal string */
  54.  
  55.  
  56. /*****************************************************************************/
  57. pascal void main(
  58.         SIHookParmBlk *parmBlk    /* Pointer to parameter block */
  59.         )
  60. /******************************************************************************
  61.     This is the main entry point for the installer hook procedure.
  62. ******************************************************************************/
  63. {
  64. RememberA0();    /* This is necessary to access any global variables */
  65. SetUpA4();
  66. parms = parmBlk;
  67.  
  68. switch (parms->function)
  69.     {
  70.     case siHookSetTargetVol:
  71.         SetTargetVolFunction();
  72.         break;
  73.  
  74.     case siHookBeginInstall:
  75.         BeginInstallFunction();
  76.         break;
  77.     }
  78. RestoreA4();
  79. }
  80.  
  81.  
  82. /*****************************************************************************/
  83. void SetTargetVolFunction(void)
  84. /******************************************************************************
  85.     Input parameters:
  86.         "targetVRefNum" - Volume reference number of target volume
  87.         "groupAPFlags", "groupQUSel", "groupVZSel" - Groups currently selected
  88.                                                                     for installation
  89.     Returns:
  90.         "groupAPFlags", "groupQUSel", "groupVZSel" - New installation groups
  91.  
  92.     This function is called at startup and whenever the target volume is
  93.     changed.
  94. ******************************************************************************/
  95. {
  96. long feature;
  97.  
  98. if (Gestalt(gestaltQuickdrawVersion, &feature) != noErr)
  99.     {    /* Gestalt could not return Quickdraw version - force abort later */
  100.     gestaltFailed = true;
  101.     return;
  102.     }
  103. if (feature < gestalt32BitQD12)
  104.     {    /* Version is lower than 1.2 - enable installation group "P" */
  105.     parms->groupAPFlags |= groupPMask;
  106.     }
  107. else
  108.     {    /* Version is 1.2 or higher - disable installation group "P" */
  109.     parms->groupAPFlags &= ~groupPMask;
  110.     }
  111. }
  112.  
  113.  
  114. /*****************************************************************************/
  115. void BeginInstallFunction(void)
  116. /******************************************************************************
  117.     Input parameters:
  118.         "targetVRefNum" - Volume reference number of target volume
  119.         "groupAPFlags", "groupQUSel", "groupVZSel" - Groups currently selected
  120.                                                                     for installation
  121.     Returns:
  122.         "result" - Hook result code
  123.  
  124.     This function is called when the install button is clicked to begin
  125.     installing files.
  126. ******************************************************************************/
  127. {
  128. long feature;
  129.  
  130. /* Abort if target machine is not running system 6.0.5 or newer */
  131. if (Gestalt(gestaltSystemVersion, &feature) != noErr)
  132.     {    /* Gestalt could not return system version - force abort */
  133.     gestaltFailed = true;
  134.     }
  135. if (gestaltFailed || (feature < 0x0605))
  136.     {    /* Newer system required - display alert then force installer to abort */
  137.     StopAlert(sysRequiredAlrt, NULL);
  138.     parms->result = siHookAbort;
  139.     }
  140. }
  141.